home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1996 / MacHack 1996.toast / Presentations / Presentations ’88 / Feldt Advanced Mac Programming / Serial Port / lib src / XTEvent.c < prev    next >
Text File  |  1987-10-26  |  2KB  |  72 lines

  1. /*                         ssg Commlib - XTEvent                            */
  2. /*                          Aztec C compiler 1.06i                            */
  3. /*                        Lightspeed C compiler 2.01                        */
  4.  
  5. /*    Copyright © 1985,1986,1987 by small systems guild.  All rights reserved.*/
  6.  
  7. #include  <extender.h>   /* include Commlib and standard Toolbox headers    */
  8.  
  9. void XTendInit()
  10. {
  11.     MoreMasters();                /* allocate a 256 byte master pointer block    */    
  12.     MoreMasters();                /* which will hold up to 64 master pointers    */
  13.     MoreMasters();                /* a master pointer is required for every    */
  14.     MoreMasters();                /* handle, which can easily be hundreds!    */
  15.                                 /* If you don't allocate them now they will    */
  16.                                 /* be automatically by the memory manager     */
  17.                                 /* as needed, causing heap fragmentation    */
  18.  
  19.     InitGraf(&thePort);            /* initialize quickdraw and initial grafport*/
  20.     InitFonts();                /* initialize the font manager                 */
  21.     InitWindows();                /* initialize the window manager            */
  22.     InitMenus();                /* initialize the menu manager                */
  23.     TEInit();                    /* initialize textedit                        */
  24.     InitDialogs(NULL);            /* initialize dialog manager after quickdraw*/
  25.                                 /* window manager, dialog manager & textedit*/    
  26.     FlushEvents(everyEvent,NULL);    /* remove all pending events from queue    */
  27.     InitCursor();                /* set cursor to the arrow pattern            */
  28. }
  29.  
  30. Boolean    XTGetNextEvent(eventMask,theEvent)
  31. int            eventMask;
  32. EventRecord    *theEvent;
  33. {
  34.     Boolean        dummy;
  35.     DialogPtr    DP;
  36.     int            item;
  37.     
  38.     if (GetNextEvent(eventMask,theEvent))    /* if there is an event on the queue*/
  39.         return(TRUE);                        /* return immediately to HandleEvent*/
  40.     else {
  41.         if (((WindowPeek)FrontWindow())->windowKind == dialogKind) {
  42.             dummy = IsDialogEvent(theEvent);
  43.             dummy = DialogSelect(theEvent,&DP,&item);
  44.         }
  45.         return(FALSE);
  46.     }
  47. }
  48.  
  49. void InitEvtStuff(ES)
  50. EventStuff      *ES;
  51. {
  52.     ES->WhichWindow = NULL; 
  53.     ES->WindowPart = -1;
  54.     ES->WhichDialog = NULL;
  55.     ES->DialogItem = 0;
  56.     ES->WhichControl = NULL;
  57.     ES->ControlPart = 0;
  58.     ES->WhichList = NULL;
  59.     ES->ListPart = -1;
  60.     SetPt(&(ES->WhichCell),-1,-1);
  61.     ES->MenuH = NULL;
  62.     ES->MenuNum = 0;
  63.     ES->ItemNum = 0;
  64.     ES->TEH = NULL;
  65.     ES->ch = '\0';
  66.     ES->SizeChanged = FALSE;
  67.     ES->WindowIsNew = FALSE;
  68.     ES->LastMouseDown.when = NULL;
  69.     ES->DoubleClick = FALSE;
  70.     ES->DialogEvent = FALSE;
  71. }
  72.